import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_rider/main/widgets/ui_constant.dart';
import 'package:flutter_rider/utils/screen_fit.dart';

class SearchWidget extends StatelessWidget {
  String hintText;
  TextEditingController? textEditingController;
  Function(String)? onChanged;
  Function()? onEditingComplete;
  SearchWidget(this.hintText,
      {this.textEditingController,
      this.onChanged,
      this.onEditingComplete,
      Key? key})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 56.rpx,
      alignment: Alignment.center,
      color: UIColor.color_content,
      padding: EdgeInsets.symmetric(vertical: 4.rpx, horizontal: 16.rpx),
      child: TextField(
        controller: textEditingController,
        style: TextStyle(color: UIColor.color_t1, fontSize: 16.rpx),
        textInputAction: TextInputAction.search,
        maxLength: 30,
        onChanged: onChanged,
        onEditingComplete: onEditingComplete,
        decoration: InputDecoration(
            counterText: "",
            contentPadding:
                EdgeInsets.symmetric(vertical: 8.rpx, horizontal: 12.rpx),
            isCollapsed: true,
            border: OutlineInputBorder(
                borderRadius: BorderRadius.all(
                  Radius.circular(20.rpx),
                ),
                borderSide: BorderSide.none),
            prefixIcon: Padding(
              padding: EdgeInsets.only(left: 10.rpx, right: 4.rpx, top: 0.rpx),
              child: Icon(
                Icons.search,
                size: 24.rpx,
                color: Colors.black.withOpacity(0.4),
              ),
            ),
            prefixIconConstraints: BoxConstraints(maxHeight: 22.rpx),
            hintText: hintText,
            hintStyle: TextStyle(
                color: Colors.black.withOpacity(0.4), fontSize: 16.rpx),
            filled: true,
            fillColor: UIColor.color_input),
      ),
    );
  }
}
